/**
 * Created by 陈奇 on 2015/4/25.
 */
var express = require('express');
var router = express.Router();
var db = require('./../routes/conn'); //先引入数据库链接

router.get('/', function(req, res) {
    var userdel = req.param('username');

    db.pool.getConnection(function(err, connection) {
        var sql = 'delete from bbs where UserName = ?';
        var sql_val = [userdel];

        connection.query(sql, sql_val, function(err, result) {
            if (err) {
                console.log('您没有权限清除用户!');
            } else {
                console.log(result);
                console.log('成功的清除用户!');
            }
        });
        connection.release();
    });

    res.render('talkDel', {
        title: '清除用户'
    });
});

module.exports = router;